<?php
/*
Template Name: download Page
*/


get_header(); ?>
<?php
$slug = get_query_var('softslug');
$slug = str_replace(array(".html"),"",$slug);
$posts = get_post_by_slug($slug);

?>
<?php if ( have_posts() ) : ?>

			<?php
			/* Start the Loop */
			foreach ($posts as $post):
			setup_postdata($post);
?>
	<div id="downloadpage" class="site-content">
		<div id="detailview" role="main" class="twocolumn">
		<div id="download_box" class="download-box">
		<h2 class="message">Chọn link tải về </h2>
			<div class="primary-download list-download" style="visibility: visible;">
				<h3 id="PrimaryLinkTitle" class="download-title">Chọn các link dưới đây để tải về</h3>
		<?php $links = get_post_meta($post->ID, 'soft_link_download', true);
		$links = json_decode($links,true);
		if(count($links)>0){
		foreach($links as $link){
		$link_name = $link['link_download'];
		if($link['link_name'] !='') $link_name = $link['link_name'];
		?>
		
		<a id="permalink" downloadurl="15812" class="download-link-button  clearfix link_download" title="Tải xuống <?php the_title(); ?> <?php echo get_post_meta($post->ID, 'soft_version', true);?>" target="_blank" rel="nofollow" href="<?php echo $link['link_download'];?>">
			<span class="link-title"><?php echo $link_name;?></span>
			<span id="DownloadLabel" class="link-download">Download</span>
				</a>
		<?php
			}
		
		}
		
		?>
				
			</div>
		</div>
				
				
		<h1 class="detail-title"><img src="<?php echo the_icon_image_url($post->ID);?>" class="software-icon"><?php the_title(); ?>
		  <em><?php echo get_post_meta($post->ID, 'soft_version', true);?></em>

                                    <i><?php echo get_post_meta($post->ID, 'soft_title_description', true);?></i>

            </h1>
			 
			<ul class="detail-info">
                    <li class="publisher-info">
                        <span class="item-label">Phát hành:</span>
                        <a href="<?php echo get_the_publisher_link();?>" target="_blank" rel="nofolow">
                            <?php echo get_the_publisher_name();?>
                        </a>
                    </li>

                                    <li class="version-info">

                        <span class="item-label">Version:</span>

                        <span class="item-info"><?php echo get_post_meta($post->ID, 'soft_version', true);?></span>

                    </li>

                <li class="license-info">

                    <span class="item-label">Sử dụng:</span>

                    <span class="item-info"><span class="<?php echo get_the_license_slug();?>"><?php echo get_the_license_name();?></span>

</span>

                </li>

                    <li class="filesize-info">

                        <span class="item-label">Dung lượng:</span>

                        <span class="item-info"><?php echo get_post_meta($post->ID, 'soft_filesize', true);?></span>

                    </li>

                <li class="dateadded-info clearfix">

                    <span class="item-label">Ngày phát hành:</span>

                    <span class="item-info"><?php echo get_the_time(); ?></span>

                </li>

                <li class="dateadded-info clearfix">

                    <span class="item-label">Ngày cập nhật:</span>

                    <span class="item-info"><?php the_modified_time(); ?></span>

                </li>				



                    <li class="requirements-info">

                        <span class="item-label">Yêu cầu:</span>

                        <span class="item-info"><?php echo get_post_meta($post->ID, 'soft_requirements_os', true);?></span>

                    </li>

            </ul>
			 <div class="content-overview">

                        <div class="detail-content">

                            <p><?php the_excerpt(); ?></p>

                        </div>

                </div>
			<div class="clear">

            </div>
			<div class="publisher-softwares">
                    <a href="<?php echo get_the_publisher_link();?>">Xem các phần mềm khác của <em><?php echo get_the_publisher_name();?></em></a>

                </div>
		</div><!-- #content -->
	</div><!-- #primary -->
<?php endforeach;?>
<?php endif;?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>